<?php

class SigninController extends Controller
{
/**
	 * Specifies the access control rules.
	 * This method is used by the 'accessControl' filter.
	 * @return array access control rules
	 */
	public function accessRules()
	{
		return array(
			array('allow',  // allow all users to perform 'index' and 'view' actions
				'actions'=>array('index','login','logout'),
				'users'=>array('*'),
			),
		);
	}
	/**
	 * This function is used for
	 */
	public function  actionLogin()
	{
	 	if(isset($_REQUEST['email']))
    	{
    		$model=new LoginForm;
    		$model->email = $_REQUEST['email'];
    		$model->password = $_REQUEST['password'];
	    	if($model->validate() && $model->login())
	    	{
	    	   echo 'true';
	    	}
	    	else {
	    		echo 'false';
	    	}
	     
	    	
    	}
	}
    /**
	 * Logs out the current user and redirect to homepage.
	 */
	public function actionLogout()
	{
		
		Yii::app()->user->logout();
		$this->redirect(Yii::app()->homeUrl.'/signin');
	}
	public function actionIndex()
	{

		$this->render('index');
    	
	}
    
	// Uncomment the following methods and override them if needed
	/*
	public function filters()
	{
		// return the filter configuration for this controller, e.g.:
		return array(
			'inlineFilterName',
			array(
				'class'=>'path.to.FilterClass',
				'propertyName'=>'propertyValue',
			),
		);
	}

	public function actions()
	{
		// return external action classes, e.g.:
		return array(
			'action1'=>'path.to.ActionClass',
			'action2'=>array(
				'class'=>'path.to.AnotherActionClass',
				'propertyName'=>'propertyValue',
			),
		);
	}
	*/
}